package cn.edu.bupt.freewings.forum.server.rest;

import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import cn.edu.bupt.freewings.forum.common.ProjectType;
import cn.edu.bupt.freewings.forum.persistence.Project;
import cn.edu.bupt.freewings.forum.persistence.ProjectDAO;
import cn.edu.bupt.freewings.forum.server.Utility.Converter;

@Path("/projects")
public class ProjectsResource {
	@GET
	@Path("/{parentId}")
	@Produces( { "application/proto", "application/xml" })
	public ProjectType.ProjectList getProjectsFromParent(
			@PathParam("parentId") @DefaultValue("0") Integer parentId) {
		List<Project> projectList = new ProjectDAO().getByParentId(parentId);
		return Converter.projectListToProjectTypeList(projectList, parentId);
	}

}
